package com.tipcp.equip.collect.config;


import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Date： 2023/9/15 16:20
 * @Author: xuliangchao
 */
@Configuration
public class SwaggerConfig {


    @Bean
    public OpenAPI openApi() {
        return (new OpenAPI())
                .addSecurityItem((new SecurityRequirement()).addList("token"))
                .components((new Components()).addSecuritySchemes("token", this.securityScheme()));
    }

    private SecurityScheme securityScheme() {
        return (new SecurityScheme())
                .in(SecurityScheme.In.HEADER)
                .name("token")
                .type(SecurityScheme.Type.APIKEY);
    }


}